XTension allows you to create 6 special scripts. These scripts are automatically executed at their appointed times.
Startup Script / Shutdown Script
On starting up, XTension will automatically execute the 'Startup Script', and conversely, the 'Shutdown Script' is executed anytime that you 'Quit' nicely out of XTension.
Obviously, you might want to always check things out or set up units into some known state on startup.
On shutdown, you might want to 'safe' some units or transfer control to another system.
These two scripts must be created as 'global' scripts. They must be named precisely as above.
Sunrise / Sunset Scripts and Times
On starting up, and every day at midnight, XTension will automatically calculate the sunrise and sunset times for your location !
( There are two verbs which allow you to offset both the sunrise and the sunset times by +/- 90 minutes ! see 'adjust sunrise/sunset' )
If you have properly set your latitude and longitude for your location using the Map control panel of your Mac, and your Mac's clock is correct, then XTension will do a reasonable job of calculating the expected times of sunrise and sunset.
Every day at the calculated sunrise time, XTension will execute a global script named 'sunrise' if you have created one. Likewise at the expected sunset time, a script named 'sunset' is executed.
If there are things that you always want to do at sunrise and/or sunset, then you must create these scripts and include the instructions you want.
Sunrise/Sunset times and whether it is 'daylight'
XTension maintains a set of internal variables which hold today's 'sunrise' time, and 'sunset' time, as well as a simple flag which designates whether it is logical for it to be 'daylight' at this location at this time. This variable is named 'daylight', and can be used in conditional scripts :
for example, the ON script of the front door motion sensor :
If daylight is false then
turn on "Front door light"
end if
You cannot set or reset this variable, it is done automatically by XTension at each sunrise/sunset.
However, you can access these time values from within a script, like this :
write log "Sunrise occurs today at " & time string for sunrise
or: write log "Sunset will be at " & time string for sunset
Additional special variables:
startup time --
This is a timestamp of the last time that XTension started up.
It is for information only, and simply gives some knowledge of how long XTension has run without failure or restart.
example : write log "Been up since " & time string for startup time
last error --
This is the number of the last 'protocol' error that XTension encountered while dealing with the X-10 interface. It is useful
only for custom diagnostics which keep track of this kind of error.
error time --
This is the timestamp of the 'last error' above.
example: write log "Last interface error was at " &
time string for error time & " on " &
date string for error time
port status --
This is a true/false indicator of whether the serial port is enabled.
It can be used in custom scripts which manage multiple copies
of XTension and whether to enable or disable the serial port.
( see the 'set port' verb for enabling/disabling the port)
example : if port status is true then
write log "The serial port is enabled"
end if
port type --
This returns an integer which represents the type of X-10 interface which is currently in use :